package com.greensecurity.sim.controller;

import com.greensecurity.sim.entity.Role;
import com.greensecurity.sim.repository.RoleRespository;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@Slf4j
@RequestMapping("/role")
@Api(description = "菜单查询")
public class RoleController {
    @Resource
    private RoleRespository respository;

    @ApiOperation(value = "查询全部角色")
    @ResponseBody
    @GetMapping("/selectAll")
    private List<Role> selectAllUser(){
        try {
            return respository.findAll();
        }catch (Exception e){
            log.error(String.valueOf(e));
            throw new RuntimeException("查询用户失败");
        }
    }
}
